
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Volume.h>

using namespace std;

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(VolumeWithSameUnit)
{
	TEST(Volume with 8 oz equals volume with 8 oz)
	{
		Volume  volume_A(8, OZ);
                Volume  volume_B(8, OZ);
                ASSERT_TRUE(volume_A == volume_B);
	}

        TEST(Volume with 8 oz not equals volume with 6 oz)
	{
		Volume  volume_A(8,OZ);
                Volume  volume_B(6,OZ);
		ASSERT_TRUE(volume_A != volume_B);
	}


        TEST(Volume with 8 tbsp equals volume with 8 tbsp)
	{
		Volume  volume_A(8,TBSP);
                Volume  volume_B(8,TBSP);
		ASSERT_TRUE(volume_A==volume_B);
	}

        TEST(Volume with 8 tbsp not equals volume with 6 tbsp)
	{
		Volume  volume_A(8,TBSP);
                Volume  volume_B(6,TBSP);
		ASSERT_TRUE(volume_A!=volume_B);
	}

        TEST(Volume with 8 tsp equals volume with 8 tsp)
	{
		Volume  volume_A(8,TSP);
                Volume  volume_B(8,TSP);
		ASSERT_TRUE(volume_A==volume_B);
	} 

        TEST(Volume with 8 tsp not equals volume with 6 tsp)
	{
		Volume  volume_A(8,TSP);
                Volume  volume_B(6,TSP);
		ASSERT_TRUE(volume_A!=volume_B);
	}           

};


FIXTURE(VolumeWithDifferentUnit)
{
	TEST(Volume with 8 oz equals volume with 24 tbsp)
	{
		Volume  volume_A(8,OZ);
                Volume  volume_B(24,TBSP);
		ASSERT_TRUE(volume_A==volume_B);
	}

        TEST(Volume with 8 oz not equals volume with 25 tbsp)
	{
		Volume  volume_A(8,OZ);
                Volume  volume_B(25,TBSP);
		ASSERT_TRUE(volume_A!=volume_B);
	}

        TEST(Volume with 8 oz equals volume with 48 tsp)
	{
		Volume  volume_A(8,OZ);
                Volume  volume_B(48,TSP);
		ASSERT_TRUE(volume_A==volume_B);
	}

        TEST(Volume with 8 oz not equals volume with 49 tsp)
	{
		Volume  volume_A(8,OZ);
                Volume  volume_B(49,TSP);
		ASSERT_TRUE(volume_A!=volume_B);
	}

        TEST(Volume with 10 tbsp equals volume with 20 tsp)
	{
		Volume  volume_A(10,TBSP);
                Volume  volume_B(20,TSP);
		ASSERT_TRUE(volume_A==volume_B);
	}

        TEST(Volume with 11 tbsp not equals volume with 20 tsp)
	{
		Volume  volume_A(11,TBSP);
                Volume  volume_B(20,TSP);
		ASSERT_TRUE(volume_A!=volume_B);
	}      
};


FIXTURE(VolumePlusWithSameUnit)
{
	TEST(Volume with 8 oz + volume with 2 oz ==Volume with 10 oz )
	{
		Volume  volume_A(8,OZ);
                Volume  volume_B(2,OZ);
                Volume  volume_C(10,OZ);
		ASSERT_TRUE(volume_C==volume_A+volume_B);
	}

        TEST(Volume with 8 tbsp + volume with 2 tbsp==Volume with 10 tbsp)
	{
		Volume  volume_A(8,TBSP);
                Volume  volume_B(2,TBSP);
                Volume  volume_C(10,TBSP);
		ASSERT_TRUE(volume_C==volume_A+volume_B);
	}

        TEST(Volume with 8 tsp + volume with 2 tsp==Volume with 10 tsp)
	{
		Volume  volume_A(8,TSP);
                Volume  volume_B(2,TSP);
                Volume  volume_C(10,TSP);
		ASSERT_TRUE(volume_C==volume_A+volume_B);
	}
};

FIXTURE(VolumePlusWithDifferentUnit)
{
    TEST(Volume with 8 oz +volume with 2 tbsp ==Volume with 26 tbsp )
	{
		Volume  volume_A(8,OZ);
                Volume  volume_B(2,TBSP);
                Volume  volume_C(26,TBSP);
		ASSERT_TRUE(volume_C==volume_A+volume_B);
	}

    TEST(Volume with 8 oz + volume with 2 tsp==Volume with 50 TSP)
	{
		Volume  volume_A(8,OZ);
                Volume  volume_B(2,TSP);
                Volume  volume_C(50,TSP);
		ASSERT_TRUE(volume_C==volume_A+volume_B);
	}

        TEST(Volume with 8 tbsp + volume with 2 tsp==Volume with 18 tsp)
	{
		Volume  volume_A(8,TBSP);
                Volume  volume_B(2,TSP);
                Volume  volume_C(18,TSP);
		ASSERT_TRUE(volume_C==volume_A+volume_B);
	}

};
        
string TESTOUTPUT(int amount, const VolumeUnit* unit)
{
        std::ostringstream stream;
        Volume volume(amount, unit);
        volume.output(stream, OZ);
        return stream.str();
}

string OUTPUT_BASEUNIT(int amount, const VolumeUnit* unit)
{
        std::ostringstream stream;
        Volume volume(amount, unit);
        volume.output(stream, BASE_VOLUME_UNIT);
        return stream.str();
}

FIXTURE(FormatOutput)
{
        TEST(Volume with 8 oz, display as"8 OZ")
        {
                ASSERT_TRUE("8 OZ"==TESTOUTPUT(8, OZ));
        }

        TEST(Volume with 2 tbsp, display as"2 TBSP")
        {
                ASSERT_TRUE("2 TBSP"==TESTOUTPUT(2, TBSP));
        }

        TEST(Volume with 1 tsp, display as"1 TSP")
        {
                ASSERT_TRUE("1 TSP"==TESTOUTPUT(1, TSP));
        }

        TEST(Volume with 7 tbsp, display as"2 OZ 1 TBSP")
        {
                ASSERT_TRUE("2 OZ 1 TBSP"==TESTOUTPUT(7, TBSP));
        }

        TEST(Volume with 9 tsp, display as"1 OZ 1 TBSP 1 TSP")
        {
                ASSERT_TRUE("1 OZ 1 TBSP 1 TSP"==TESTOUTPUT(9, TSP));
        }

        TEST(Volume with 13 tsp, display as"2 OZ 1 TSP")
        {
                ASSERT_TRUE("2 OZ 1 TSP"==TESTOUTPUT(13, TSP));
        }

        TEST(Volume with 10 tbsp, display as"20 TSP")
        {
                ASSERT_TRUE("20 TSP"==OUTPUT_BASEUNIT(10, TBSP));
        }

        TEST(Volume with 30 tsp, display as"30 TSP")
        {
                ASSERT_TRUE("30 TSP"==OUTPUT_BASEUNIT(30, TSP));
        }

        TEST(Volume with 3 oz, display as"18 TSP")
        {
                ASSERT_TRUE("18 TSP"==OUTPUT_BASEUNIT(3, OZ));
        }
};
